package some.board.dao;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import some.board.domain.BoardCommand;

@Component
public class BoardDaoImpl extends SqlSessionDaoSupport implements BoardDao{

	@Override
	public List<BoardCommand> list(Map<String, Object> map) {
		List<BoardCommand> list = getSqlSession().selectList("boardDao.selectList",map);
		return list;
	}

	@Override
	public List<BoardCommand> noticeList(Map<String, Object> map) {
		List<BoardCommand> noticeList = getSqlSession().selectList("boardDao.noticeList",map);
		return noticeList;
	}

	@Override
	public int getRowCount(Map<String, Object> map) {
		return getSqlSession().selectOne("boardDao.selectCount",map);
	}

	@Override
	public int getNoticeCount(Map<String, Object> map) {
		return getSqlSession().selectOne("boardDao.selectNoticeCount",map);
	}

	@Override
	public void insert(BoardCommand board) {
		getSqlSession().insert("boardDao.insertBoard",board);
	}

	@Override
	public BoardCommand selectBoard(Integer num) {
		BoardCommand command = 
				(BoardCommand)getSqlSession().selectOne("boardDao.selectBoard",num);
		return command;
	}

	@Override
	public void updateHit(Integer num) {
		getSqlSession().update("boardDao.updateHit",num);
	}

	@Override
	public void update(BoardCommand boardCommand) {
		getSqlSession().update("boardDao.updateBoard",boardCommand);
	}

	@Override
	public void delete(Integer num) {
		getSqlSession().delete("boardDao.deleteBoard",num);
	}

}
